home *** CD-ROM | disk | FTP | other *** search
/ Tricks of the 3D Game Programming Gurus / gurus.iso / DirectX / dx9sdkcp.exe / SDK (C++) / Samples / Media / Ripple.vsh < prev    next >
Encoding:
Text File  |  2002-11-12  |  1.3 KB  |  71 lines

  1. vs.1.1
  2. ; Constants:
  3. ;
  4. ;  c0-c3  - View+Projection matrix
  5. ;
  6. ;  c4.x   - time
  7. ;  c4.y   - 0
  8. ;  c4.z   - 0.5
  9. ;  c4.w   - 1.0
  10. ;
  11. ;  c7.x   - pi
  12. ;  c7.y   - 1/2pi
  13. ;  c7.z   - 2pi
  14. ;  c7.w   - 0.05
  15. ;
  16. ;  c10    - first 4 taylor coefficients for sin(x)
  17. ;  c11    - first 4 taylor coefficients for cos(x)
  18.  
  19. dcl_position v0
  20.  
  21. ; Decompress position
  22. mov r0.x, v0.x
  23. mov r0.y, c4.w       ; 1
  24. mov r0.z, v0.y
  25. mov r0.w, c4.w       ; 1
  26.  
  27. ; Compute theta from distance and time
  28. mov r4.xz, r0        ; xz
  29. mov r4.y, c4.y       ; y = 0
  30. dp3 r4.x, r4, r4     ; d2
  31. rsq r4.x, r4.x
  32. rcp r4.x, r4.x       ; d
  33. mul r4.xyz, r4, c4.x     ; scale by time
  34.  
  35. ; Clamp theta to -pi..pi
  36. add r4.x, r4.x, c7.x
  37. mul r4.x, r4.x, c7.y
  38. frc r4.xy, r4.x
  39. mul r4.x, r4.x, c7.z
  40. add r4.x, r4.x,-c7.x
  41.  
  42. ; Compute first 4 values in sin and cos series
  43. mov r5.x, c4.w       ; d^0
  44. mov r4.x, r4.x       ; d^1
  45. mul r5.y, r4.x, r4.x ; d^2
  46. mul r4.y, r4.x, r5.y ; d^3
  47. mul r5.z, r5.y, r5.y ; d^4
  48. mul r4.z, r4.x, r5.z ; d^5
  49. mul r5.w, r5.y, r5.z ; d^6
  50. mul r4.w, r4.x, r5.w ; d^7
  51.  
  52. mul r4, r4, c10      ; sin
  53. dp4 r4.x, r4, c4.w
  54.  
  55. mul r5, r5, c11      ; cos
  56. dp4 r5.x, r5, c4.w
  57.  
  58. ; Set color
  59. add r5.x, -r5.x, c4.w ; + 1.0
  60. mul oD0, r5.x, c4.z   ; * 0.5
  61.  
  62. ; Scale height
  63. mul r0.y, r4.x, c7.w
  64.  
  65. ; Transform position
  66. dp4 oPos.x, r0, c0
  67. dp4 oPos.y, r0, c1
  68. dp4 oPos.z, r0, c2
  69. dp4 oPos.w, r0, c3
  70.  
  71.